Skip to main content

Chatbot APIs

Endpoint: /start_conversation

https://api.botlhale.xyz/start_conversation
tip

You need to include an Authentication Token in request headers. See the Authentication page of this documentation for information on how to generate authentication token codes.

Method:POST

This endpoint initiates a new conversation or continues an existing one by generating or validating a conversation_id.

Authentication

A valid Bearer token must be included in the request headers for authentication.

Headers:

  • Authorization: Bearer <your_token>
Request ParamsTypeData TypeDescription
bot_idstringRequiredSpecifies which bot the conversation is associated with.
language_codestringRequiredThe language code for the conversation.
conversation_idstringOptionalA unique ID to track the conversation. Auto-generated if not provided.
user_idstringOptionalDefaults to conversation_id if not provided.
platformstringOptionalDefaults to API if not provided.

Response

The API returns a JSON object with the following structure:

Unset
{
"conversation_id": "conv_123456",
"user_id": "user_789",
"language_code": "en-ZA",
"platform": "API"
}

Fields:

Request ParamsData TypeDescription
conversation_idstringThe unique ID for the conversation.
user_idstringThe user ID associated with the conversation.
language_codeintegerThe language code for the conversation
platformstringThe platform from which the request originated.

Endpoint: /message

https://api.botlhale.xyz/message
tip

You need to include an Authentication Token in request headers. See the Authentication page of this documentation for information on how to generate authentication token codes.

Method:POST

This endpoint handles user messages and returns the bot's response in JSON format. It supports different message types such as text, image, PDF, and speech.

Authentication

A valid Bearer token must be included in the request headers for authentication.

Headers:

  • Authorization: Bearer <your_token>
Request ParamsTypeData TypeDescription
bot_idstringRequiredSpecifies which bot the message should be sent to.
language_codestringRequiredThe language the user is using to interact with the bot.
conversation_idstringRequiredA unique ID to keep track of different conversations.
text_msgstringRequired if message_type is textThe text message from the user to the bot.
image_urlstringRequired if message_type is imageThe URL of the image to be processed.
pdf_urlstringRequired if message_type is pdfThe URL of the PDF to be processed.
speech_filefileRequired if message_type is speechThe binary audio file of the user's message.
message_typestringOptionalSpecifies the type of user message. Supported values:'text','image','pdf' and 'speech'.
response_typestringOptionalSpecifies the desired response format. Supported values:'text' and 'speech'.
platformstringOptionalDefaults to 'API' if not provided.
user_idstringOptionalDefaults to the conversation_id if not provided.

Request Example

import requests

url = "https://api-dev.botlhale.xyz/start_conversation"

payload = {'language_code': 'en-ZA',
'BotID': '{{BotID}}'}
files=[

]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Text - Text example request

curl --location --request POST 'https://api.botlhale.xyz/message' \
-H "Authorization: Bearer <IdToken>" \
--form 'bot_id="<bot_id>"' \
--form 'language_code="English"' \
--form 'conversation_id="<conversation_id>"' \
--form 'message_type="text"' \
--form 'response_type="text"' \
--form 'text_msg="text"'

Response body

{
"text_msg": "Hello, how can I assist you?",
"transcription": "Hello bot",
"speech_response_url": "https://example.com/audio.mp3",
"message_id": "msg_123456",
"conversation_id": "conv_789",
"user_id": "user_789",
"bot_id": "bot_001",
"language_code": "en-US",
"date_received": "2025-01-28T10:00:00Z",
"text_response": "Hi! How can I help you today?",
"intent": "greeting",
"entities": [],
"buttons": [],
"confidence": "0.95",
"custom": {}
}

Fields:

Request ParamsData TypeDescription
text_msgstringThe text message from the user (if message_type is 'text').
transcriptionstringThe transcribed text from the speech input (if message_type is 'speech').
speech_response_urlstringThe URL of the bot’s speech response (valid for 24 hours, if response_type is 'speech').
message_idstringThe unique identifier for the message.
conversation_idstringThe unique ID tracking the conversation.
user_idstringThe user ID associated with the conversation.
bot_idstringThe bot that received the message.
language_codestringThe language in which the conversation is taking place.
date_receivedstringThe date and time when the request was received, in ISO 8601 format.
text_responsestringThe bot's text response to the user.
intentstringThe detected intent of the user’s message.
entitieslistAny extracted entities from the user’s message.
buttonslistAny interactive buttons provided in the bot’s response.
confidencestringThe confidence score of the detected intent.
customdictAny additional custom fields returned by the bot.

Contact us

info

We are here to help! Please contact us with any questions.